package com.codeduck.injection.config;

import com.codeduck.injection.entity.Phone;
import com.codeduck.injection.impl.MyCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @author: <a href="mailto:codeduck@163.com">Codeduck</a>
 * @createDate: 2021-12-24
 */
@Configuration
public class ConditionBeanConfig {

    /**
     * 测试方法 {@link com.codeduck.injection.ConditionBeanConfigTest}
     *
     * 在Windows环境下，User这个组件将被成功注册，如果是别的操作系统，这个组件将不会被注册到IOC容器中。
     */
    @Bean
    @Conditional(MyCondition.class)
    public Phone phone() {
        return new Phone();
    }
}
